﻿/*!
 * 远光ECP平台3.4版本 
 * 
 * 可见窗口基类.：qzz.ui.text
 * ecp.qzz.ui.text.js
 * @requires qzz.ui
 */

/**
 *可见控件命名空间
 *@name qzz.ui
 *@namespace qzz.ui
 */
define(["qzz.window"], function() {
	
	var qzz = window.qzz;
	
	qzz.space("ui");
	
	/**
	 @description 可见控件基类 
	<pre> 
	此类作为可见控件的基类来应用。
	</pre>
	@class qzz.ui.text 可见控件基类
	@extends qzz.window
	@property
	@example
	@author qinzhenzhou@ygsoft.com
	@version 1.0
	@date 2017-05-31
	*/	
	qzz.ui.text = qzz.Class(qzz.ui.window, 
	/**@lends qzz.ui.text# */	
	{
	    /**
	     * 对象创建函数.
	     */
	    _create:function() {
            this.className = "Text";
            this.base();
            this.getOption().width = this.getNumberValue(this.getOption().width, 100);
            this.getOption().height = this.getNumberValue(this.getOption().height, 30);
            this.getOption().ellipsis = this.getBooleanValue(this.getOption().ellipsis, false);
            this.getOption().text = this.getOption().value || "";
            this.getOption().verticalAlign = this.getOption().verticalAlign || "middle";
	    },
	    /**
	     * 渲染函数.
	     */
	    _render:function() {
	    	this.base();
	    	this.thisWindow.style.verticalAlign = this.getOption().verticalAlign;
	    	this.refresh();	    	
	    },
	    
	    refresh:function() {
//	    	if(this.getOption().ellipsis === true) {
//	    		this.delStyle(this.thisWindow, "text_table_cell");
//	    		this.addStyle(this.thisWindow, "text_table_ellipsis");
//	    		this.thisWindow.style.lineHeight = this.getHeight() + "px";
//	    	} else {
//	    		this.delStyle(this.thisWindow, "text_table_ellipsis");
//	    		this.addStyle(this.thisWindow, "text_table_cell");	
//	    		this.thisWindow.style.lineHeight = "";
//	    	}
	    	this.addStyle(this.thisWindow, "text_table_cell");
	    	var str = this.getOption().value || "";
	    	if(str !== "" && this.getOption().ellipsis === true) {
	    		str = this.getShowStr(str, this.getOption().fontSize, this._getRectWidth() - 8, this._getRectHeight());
	    	}
	    	if(this.getOption().value != null && this.getOption().value != str) {
	    		this.thisWindow.setAttribute("title", this.getOption().value);
	    	}
	    	this.thisWindow.innerHTML = str;
	    },
	    
	    value:function(value) {
	    	if(value == null) {
	    		return this.getOption().value;
	    	} else {
	    		this.getOption().value = value;
	    		this.refresh();
	    	}
	    }
	    
	});
	/**
	 * 文本控件.
	 */
	_bindRenderFunc("qzztext", qzz.ui.text);
	return qzz.ui.text;
});